home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / LProgressIndicator & Friends / LThermometerPane / WindoidUtil.c < prev    next >
Encoding:
Text File  |  1995-04-28  |  1.7 KB  |  68 lines  |  [TEXT/CWIE]

  1. // * This module contains functions borrowed
  2. // * from the Infinity Windoid, written by Troy Gaul.
  3. // * ©1991-1995 Infinity Systems.  All Rights Reserved.
  4.  
  5. //#include "WindoidTypes.h"
  6. #include "WindoidUtil.h"
  7.  
  8. static void 
  9. UseDefaultColor(short index, RGBColor *theColor) {
  10.     switch (index) {
  11.         case wContentColor:            //     0
  12.         case wTitleBarColor:        //     4
  13.         case wHiliteColorLight:        //     5
  14.         case wTitleBarLight:        //     7
  15.             theColor->red = theColor->green = theColor->blue = 0xFFFF;
  16.             break;
  17.                 
  18.         case wDialogLight:            //     9
  19.         case wTingeLight:            //    11
  20.             theColor->red = theColor->green = 0xCCCC;
  21.             theColor->blue = 0xFFFF;
  22.             break;
  23.         
  24.         case wTingeDark:            //    12
  25.             theColor->red = theColor->green = 0x3333;
  26.             theColor->blue = 0x6666;
  27.             break;
  28.  
  29.         default:
  30.             theColor->red = theColor->green = theColor->blue = 0;
  31.             break;
  32.     }
  33. }
  34.  
  35. // -----------------------------------------------------------------------------
  36.  
  37. void 
  38. GetWctbColor(WindowPeek window, short partCode, RGBColor *theColor) {
  39.     
  40.     //    Given a partCode, return the RGBColor associated with it. (Using the
  41.     //    default window color table.)
  42.     
  43.     AuxWinHandle awHndl;
  44.     short count;
  45.     
  46.     
  47.     //    Get the Color table for the window if it has one.
  48.  
  49.     (void) GetAuxWin((WindowPtr) window, &awHndl); 
  50.     count = (**(WCTabHandle) ((**awHndl).awCTable)).ctSize;
  51.     
  52.  
  53.     //    If the table didn't contain the entry of interest, look to the 
  54.     //    default table.
  55.     
  56.     if (count < partCode) {
  57.         GetAuxWin(nil, &awHndl); 
  58.         count = (**(WCTabHandle) ((**awHndl).awCTable)).ctSize;
  59.     }
  60.             
  61.  
  62.     //    If the entry is there, use it, if not make a best guess at a default value.
  63.  
  64.     if (count < partCode)
  65.         UseDefaultColor(partCode, theColor);
  66.     else
  67.         *theColor = (**(WCTabHandle) ((**awHndl).awCTable)).ctTable[partCode].rgb;
  68. }